<?php
function CodeHighLighter_ContentReplacer($matches)
{
	global $suri;
	if (strlen($matches[1]) == 0) {
		$matches[1] = 'Cpp';
	}

	if($suri['directive']!="/rss" && $suri['directive']!="/m" && $suri['directive']!="/i/entry") {
		return '<textarea name="CodeHighLighterCode" class="' . str_replace(array('(', ')'), array('[', ']'), trim($matches[1])) . '" cols="60" rows="10" readonly="readonly">' .
		preg_replace('@<br\\s*/?>@Ui' , "\r\n", $matches[2]) .
		'</textarea>';
	} else {
		return $matches[2];
	}
}

function CodeHighLighter_DressContent($mother, $id)
{
	return preg_replace_callback('@\\[CODE([^\\]]*)\\](.*)\\[/CODE\\]@Usi', 'CodeHighLighter_ContentReplacer', $mother);
}

function CodeHighLighter_ApplyCSS($mother)
{
	global $pluginURL;
	return $mother . '<link type="text/css" rel="stylesheet" href="' . $pluginURL . '/Styles/SyntaxHighlighter.css" />';
}

function CodeHighLighter_ApplyScript($mother)
{
	global $pluginURL;
	$scriptFiles = array( 'shCore.js', 'shBrushCSharp.js', 'shBrushXml.js', 
		'shBrushCpp.js', 'shBrushCss.js', 'shBrushJava.js', 'shBrushJScript.js', 'shBrushPhp.js', 'shBrushPython.js',
		'shBrushRuby.js', 'shBrushSql.js', 'shBrushVb.js');
	foreach ($scriptFiles as $scriptFile) {
		$mother .= '<script type="text/javascript" language="javascript" src="' . $pluginURL . '/Scripts/' . $scriptFile . '"></script>' . "\r\n";
	}
	$mother .= '<script type="text/javascript" language="javascript">
	//<![CDDA[
    	dp.SyntaxHighlighter.HighlightAll(\'CodeHighLighterCode\');  
	//]]>
	</script>
';
	return $mother;
}

?>